﻿$(function () {
    var submitAction = function () {
        var code = $("#securityCodeRequest #codeValue").attr("value");

        $.post('/Security/EnsureSecurity', { code: code }, function (data) {
            if (data.CheckResult == "success") {
                $("#securityCodeRequest").dialog("close");
            } else {
                var newCode = data.newCode;
                $("#securityCodeRequest p").first().html('<p>Please, enter code # ' + newCode + '</p>');
            }
        });
    };

   securityWnd = $("#securityCodeRequest").dialog({
        modal: true,
        buttons: [{ text: "SUBMIT", click: submitAction}],
        resizable: false,
        closeOnEscape: false,
        dialogClass: "no-close",
        draggable: false
    });
});